package xiecheng;

import java.util.Scanner;

/**
 * @author Hang
 * @date 2022/8/30
 * @project AutumnOffer
 * @description
 **/
public class Solution1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n];
        for(int i=0;i<n;i++){
            t[i] = sc.nextInt();
        }
        for(int i=0;i<n;i++){
            System.out.println(res(t[i]));
        }
    }
    public static int res(int s){
        if(s%2==0) return s;
        else{
            int tmp = s;
            int base = 1;
            while(s != 0){
                if(s%2==1){
                    s = s / 10;
                    base *= 10;
                }else{
                    int f = tmp / base;
                    int h = f % 10;
                    int g = tmp % base;
                    int r = (f / 10)*10*base+g*10+h;
                    return r;
                }
            }
            return -1;
        }
    }
}
